package com.example.mygame.service;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.mygame.R;
import com.example.mygame.pojo.Friend;

import java.util.List;

public class MyFriendAdopter extends BaseAdapter {

    private List<Friend> data;

    private Context context;

    public MyFriendAdopter(List<Friend> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }



    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_addfriend, parent, false);
        }
        TextView name = (TextView) convertView.findViewById(R.id.name);

        name.setText(data.get(position).getFriendname());

        return convertView;
    }
}
